import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { mockDevServerPlugin } from 'vite-plugin-mock-dev-server'
import crypto from 'crypto-browserify'

// 修复crypto问题
globalThis.crypto = crypto

export default defineConfig({
  plugins: [
    vue({
      template: {
        compilerOptions: {
          // 完全禁用hash生成
          hash: false
        }
      }
    }),
    mockDevServerPlugin({
      prefix: '/api',
      mockPath: './mock'
    })
  ],
  resolve: {
    alias: {
      crypto: 'crypto-browserify'
    }
  },
  optimizeDeps: {
    include: ['crypto-browserify']
  }
})